import urllib.request
#引入ProxyHandler
from urllib.request import ProxyHandler
url = "https://m.douban.com/rexxar/api/v2/subject/recent_hot/movie?start=20&limit=120&ck=efdK"
headers = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36',
    'referer':'https://movie.douban.com/explore'
}
req = urllib.request.Request(url,headers=headers)
#使用https的代理访问
# phandler = ProxyHandler({"https":"110.43.221.121:7088"})
#socks5协议的代理
phandler = ProxyHandler({"https":"socks5h://117.161.170.163:9021"})
opener = urllib.request.build_opener(phandler)
resp = opener.open(req)
json = resp.read().decode("utf-8")
print(json)